package com.xh.bussiness.permission.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.bussiness.permission.dao.UserSchoolMapper;
import com.xh.bussiness.permission.model.School;
import com.xh.bussiness.permission.model.UserSchool;
import com.xh.bussiness.permission.service.IUserSchoolService;
import com.xh.core.service.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 *
 * </p>
 *
 * @author Pitt zhang
 * @since 2019/10/16
 */
@Service
public class UserSchoolServiceImpl extends BaseServiceImpl<UserSchoolMapper, UserSchool> implements IUserSchoolService {

    @Override
    public List<UserSchool> queryUserSchoolByUserId(String userId) {
        QueryWrapper<UserSchool> qw = new QueryWrapper<>();
        qw.eq("user_id", userId);
        List<UserSchool> schools = this.dao.selectList(qw);
        if (!CollectionUtils.isEmpty(schools)) {
            return schools;
        }
        return null;
    }

    @Override
    public List<School> querySchoolByUserId(String userId) {
        return this.dao.selectSchoolByUserId(userId);
    }

    @Override
    public boolean deleteByUserId(String userId) {
        return this.dao.deleteByUserId(userId);
    }
}
